//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.quickserver.net.qsadmin.gui;

import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.apache.commons.digester3.Digester;
import org.quickserver.util.MyString;

public class PropertieSet {
    private static Logger logger = Logger.getLogger(PropertieSet.class.getName());
    private List list = new ArrayList();
    private Map map = new HashMap();

    public PropertieSet() {
    }

    public List getList() {
        return this.list;
    }

    public Map getMap() {
        return this.map;
    }

    public void addCommand(Propertie p) {
        this.list.add(p);
        this.map.put(p.getCommand(), p);
    }

    public static PropertieSet getPropertieSet() {
        PropertieSet ps = null;

        try {
            Digester digester = new Digester();
            digester.setValidating(false);
            String mainTag = "propertie-set";
            String subTag = "propertie";
            digester.addObjectCreate(mainTag, PropertieSet.class);
            digester.addObjectCreate(mainTag + "/" + subTag, Propertie.class);
            digester.addBeanPropertySetter(mainTag + "/" + subTag + "/name");
            digester.addBeanPropertySetter(mainTag + "/" + subTag + "/command");
            digester.addCallMethod(mainTag + "/" + subTag + "/get", "setGet", 0);
            digester.addCallMethod(mainTag + "/" + subTag + "/set", "setSet", 0);
            digester.addBeanPropertySetter(mainTag + "/" + subTag + "/type");
            digester.addBeanPropertySetter(mainTag + "/" + subTag + "/desc");
            digester.addBeanPropertySetter(mainTag + "/" + subTag + "/select");
            digester.addBeanPropertySetter(mainTag + "/" + subTag + "/target-needed", "targetNeeded");
            digester.addBeanPropertySetter(mainTag + "/" + subTag + "/version");
            digester.addSetNext(mainTag + "/" + subTag, "addCommand");
            URL configFile = PropertieSet.class.getResource("/org/quickserver/net/qsadmin/gui/conf/PropertieSet.xml");
            if (configFile == null) {
                throw new RuntimeException("XML File not found : PropertieSet.xml");
            }

            InputStream input = configFile.openStream();
            logger.fine("Loading command config from xml file : " + input);
            ps = (PropertieSet)digester.parse(input);
        } catch (Exception var6) {
            logger.severe("Could not init from xml file : " + var6);
            logger.fine("StackTrace:\n" + MyString.getStackTrace(var6));
        }

        return ps;
    }
}
